<%--
  - Author		:	최 재원(Jaewon Choi)
  - Date			:	2013.10.28
  - Description	:	
  --%>
<%@ page language="java" %>
<%@ page contentType="text/html; charset=utf-8" %>
<%@ page pageEncoding="utf-8"%>
<%@ include file="/WEB-INF/pages/includes/taglibs.jspf" %>
<%@ include file="/WEB-INF/pages/includes/variables.jspf" %>
<%@ include file="/WEB-INF/pages/includes/doctype.jspf" %>
<html>
	<head>
<%@ include file="/WEB-INF/pages/includes/metatags.jspf" %>		
		<title><fmt:message key="pages.title" /></title>	    
		<meta name="viewport" content="width=device-width, initial-scale=1.0,minimum-scale=1.0,maximum-scale=2.0">
		<style type="text/css">
			body {margin:0; padding:0; font-family:돋움, dotum, Arial, sans-serif; font-size:12px; color:#000000; background-color:#FFFFFF;}
			
			#Left {position:absolute; top:0; left:0; width:20px;}
			#Center {margin:0 20px 0 20px;}
			#Right {position:absolute; top:0; right:0; width:20px;}
		
		</style>
		<!-- jQuery --> 
	    <script src="<c:url value="${dirScripts}/event/jquery-1.8.2.min.js" />" type="text/javascript"></script> 
		<script type="text/javascript">
			function goEvent(eventIdx, link, obj){
				$(obj).next().toggle();
				var imgObj = $(obj).children().first().children().first();
				$(imgObj).attr("src", "<c:url value="${dirImages}/btn_event_on.png" />");
				//var data = '[{"cmd":"contInsert","userIdx":1,"title":"멍멍이를 찾습니다.","contDesc":"테스트 내용입니다.","happenDate":"2013-04-25","happenTime":"1","address":"서울시 강남구 논현동","latitude":37.5123413,"longitude":127.028287,"categoryIdx":1,"reward":1000000}]';
				//var data = '[{"cmd":"contModify", "contIdx":2, "userIdx":1, "title":"멍멍이를 찾습니다.","contDesc":"테스트 내용입니다.","happenDate":"2013-04-25","happenTime":"1","address":"서울시 강남구 논현동","latitude":37.5123413,"longitude":127.028287,"categoryIdx":1,"reward":1000000}]';
				//var data = '[{"cmd":"contEnd", "contIdx":2, "userIdx":1, "finish":1}]';
				//var data = '[{"cmd":"contDel", "contIdx":2 , "userIdx":13}]';
				//var data = '[{"cmd":"commentInsert","userIdx":1,"contIdx":5,"cont":"테스트 내용입니다."}]';
				//var data = '[{"cmd":"commentDel", "contIdx":2 , "commentIdx":2, "userIdx":13}]';
				var data = '[{"categoryIdx":1,"title":"ㄱㄴㄷ","cmd":"contInsert","reward":111,"address":"서울특별시 강남구 선릉로145길 11","userIdx":1,"longitude":127.03859847038986,"latitude":37.521312192316365,"happenTime":"1","contDesc":"ㄱㄴㄷ","happenDate":"2014-2-4"}]'; 
				document.frm.data.value = data;
				
				$.ajax({
					type: "POST",
					url: "<c:url value="/API/v1_0/contIn" />",
					//url: "<c:url value="/API/v1_0/commentUp" />",
					dataType: "json",
					async: false,
					data: $(document.frm).serialize(),
					success: function(data){
						if(data.returnCode == "000"){
							//location.href = link;
							alert(data.contIdx);							
						}else{
							alert(data.returnMessage);
						}
					},
					beforeSend: function(){
					},
					error: function(jqXHR, textStatus, errorThrown){
						alert("오류가 발생하였습니다.\n관리자에게 문의 바랍니다.");
						throw errorThrown;
					},
					complete: function(){
					}
				 });				
			}
			
			function goSubmit(){
				// var data = '[{"cmd":"contInsert","userIdx":1,"title":"멍멍이를 찾습니다.","contDesc":"테스트 내용입니다.","happenDate":"2013-04-25","happenTime":"1","address":"서울시 강남구 논현동","latitude":37.5123413,"longitude":127.028287,"categoryIdx":1,"reward":1000000}]';
				//var data = '[{"cmd":"contModify", "contIdx":2, "userIdx":1, "title":"멍멍이를 찾습니다.","contDesc":"테스트 내용입니다.","happenDate":"2013-04-25","happenTime":"1","address":"서울시 강남구 논현동","latitude":37.5123413,"longitude":127.028287,"categoryIdx":1,"reward":1000000}]';
				//var data = '[{"cmd":"contEnd", "contIdx":2, "userIdx":1, "finish":1}]';
				//var data = '[{"cmd":"contDel", "contIdx":2 , "userIdx":13}]';
				var data = '[{"categoryIdx":1,"title":"ㄱㄴㄷ","cmd":"contInsert","reward":111,"address":"서울특별시 강남구 선릉로145길 11","userIdx":1,"longitude":127.03859847038986,"latitude":37.521312192316365,"happenTime":"1","contDesc":"ㄱㄴㄷ","happenDate":"2014-2-4"}]';
				document.frm.data.value = data;
				
				document.frm.action = "<c:url value="/API/v1_0/contIn" />";
				document.frm.submit();			
			}
		</script>	    
	</head>
	<body background="#FFFFFF">    
		<div id="Left">&nbsp;</div>
		<div id="Center">				
			<center>
						<img id="detailImg" width="100%" class="detailImg" src="${param.detail_img}" />				
					<br />
					<a href="javascript:goEvent('${param.event_idx}','${param.link}', this)">
					<img width="30%" class="eventImgUrl" src="<c:url  value="${dirImages}/btn_event_off.png" />">
					</a>
			</center>
		</div>
		<div id="Right">&nbsp;</div>
	    <!-- <form name="frm" method="post" style="display: none;"> -->
	    <form name="frm" method="post" enctype="multipart/form-data">
			<input type="hidden" name="device_id" value="${param.device_id}" />
			<input type="hidden" name="model" value="${param.model}" />
			<input type="hidden" name="os_ver" value="${param.os_ver}" />
			<input type="hidden" name="lcd_size" value="${param.lcd_size}" />
			<input type="hidden" name="store_type" value="${param.store_type}" />
			<input type="hidden" name="app_id" value="${param.app_id}" />
			<input type="hidden" name="app_ver" value="${param.app_ver}" />
			<input type="hidden" name="data" />			
			
			<!-- 
			 <input type="file" name="contFiles" />			 
			-->
			
			<input type="file" name="contFile1" />
			<input type="file" name="contFile2" />
			<input type="file" name="contFile3" />
			 
			 
			<input type="button" name="button" onclick="goSubmit();">
		</form>
	</body>
</html>